import type { App, VNode } from 'vue'
import { createVNode, render } from 'vue'
import Loading from './index.vue'

// loading插件
export default {
  install(app: App, ...args: Array<any>) {
    const vnode: VNode = createVNode(Loading)
    render(vnode, document.body)
    app.config.globalProperties.$$loading = {
      show: vnode.component?.exposed?.show,
      hide: vnode.component?.exposed?.hide,
    }
  }
}

// 类型声明
interface LoadingType { show: Function, hide: Function }



declare module 'vue' {
  export interface ComponentCustomProperties {
    $$loading: LoadingType
  }
}

// declare module '@vue/runtime-core' {
//   export interface ComponentCustomProperties {
//     $$$loading: LoadingType
//   }
// }


